package com.mymobile.showcase.mobile;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.event.ActionEvent;

import com.hmsproject.common.HMSManagedBeans;
import com.hmsproject.datastructures.User;
import com.hmsproject.db.util.HMSDBUtil;

@ManagedBean
@ViewScoped
public class UserView {

    User user;
    
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@PostConstruct
	private void init(){
		System.out.println("EMAIL " + HMSManagedBeans.getHMSManagedBeans().getEmailAddress());
		this.user = HMSDBUtil.getInstance().getUser(HMSManagedBeans.getHMSManagedBeans().getEmailAddress());
	}

	public void updateUser(ActionEvent event)
	{
		HMSDBUtil.getInstance().updateUser(this.user);
	}

}

